//
//  CSBAIrChatCell.swift
//  CurSodoboAer
//
//  Created by CurSodoboAer on 2024/11/5.
//

import UIKit

class CSBAIrChatCell: UITableViewCell {
    private var csbBayui = [Int]()
    private let csbNUmber = Array(repeating: 10, count: 64)
    private let csbNumbe2 = Array(repeating: 96, count: 50)
    private var cabSunmAll: Int = 0
    
    
    var csbColoter:UIColor = .brown
    var csbFplowe:CGFloat = 23.1
    var csbHeihei:UIFont?
    
    
    let mychatContetnCSBLab = UILabel.init()
    let chatBackfCSB = UIView.init()
    
    func updateUIREmaklCSB(ismeCSB:Bool) {
        csbBayui.append(11)
        cabSunmAll = csbNUmber.count
        if cabSunmAll > 5 {
            csbBayui.append(contentsOf: csbNUmber)
        }else{
            csbBayui.append(contentsOf: csbNumbe2)
        }

        csbBayui.append(contentsOf: [52, 6, 11])
        csbBayui.removeLast()
        cabSunmAll = csbBayui.count

       
        if ismeCSB == true && (cabSunmAll >= 0){
           
            chatBackfCSB.backgroundColor = .clear
            chatBackfCSB.layer.borderColor = UIColor.white.cgColor
            chatBackfCSB.layer.borderWidth = 1
            mychatContetnCSBLab.textAlignment = .right
            chatBackfCSB.snp.remakeConstraints { make in
                make.width.lessThanOrEqualTo(310.xQQ)
                if (cabSunmAll >= 0) && (csbBayui.count >= 0) {
                    make.right.equalToSuperview().inset(12.xQQ)
                    make.top.bottom.equalToSuperview().inset(14)
                }
               
               
                make.width.greaterThanOrEqualTo(65.xQQ)
            }
        }else{
           
            chatBackfCSB.backgroundColor = UIColor(red: 0.07, green: 0.07, blue: 0.07, alpha: 1)
            mychatContetnCSBLab.textAlignment = .left
            chatBackfCSB.snp.remakeConstraints { make in
                make.width.lessThanOrEqualTo(310.xQQ)
                make.left.equalToSuperview().inset(12.xQQ)
                make.top.bottom.equalToSuperview().inset(14)
               
                make.width.greaterThanOrEqualTo(65.xQQ)
            }
            
            
        }
    }
    
  
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        backgroundColor = .clear
        contentView.addSubview(chatBackfCSB)
        chatBackfCSB.addSubview(mychatContetnCSBLab)
        mychatContetnCSBLab.font = UIFont(name: "Helvetica", size: 15)
        mychatContetnCSBLab.textColor = .white
        chatBackfCSB.backgroundColor = UIColor.white
        chatBackfCSB.layer.cornerRadius = 20
        chatBackfCSB.layer.masksToBounds = true
        chatBackfCSB.contentMode = .scaleAspectFill
        var ikol = ["csbFplowe":csbFplowe]
        if self.backgroundColor == .brown {
            ikol["allElseTigerCSB"]  = 77.8
            csbFplowe += 1.1
        }else{
            csbFplowe += 2.1
        }

        if csbFplowe < 10{
            return
        }
        chatBackfCSB.snp.makeConstraints { make in
            make.width.lessThanOrEqualTo(310.xQQ)
            make.right.equalToSuperview().inset(12.xQQ)
            make.top.bottom.equalToSuperview().inset(14)
           
            make.width.greaterThanOrEqualTo(65.xQQ)
        }
        
        mychatContetnCSBLab.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview().inset(17.xQQ)
            make.top.bottom.equalToSuperview().inset(16.xQQ)
        }
    }

    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}



